﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using HigLabo.Net;

namespace HigLabo.WindowsAzure.RestService.ServiceManagement
{
    public class UpdateHostedServiceCommand : ManagementServiceCommand<UpdateHostedServiceResult>
    {
        /// <summary>
        /// 対象サービス名
        /// </summary>
        public String ServiceName { get; private set; }

        /// <summary>
        /// リクエストのボディ
        /// </summary>
        public UpdateHostedServiceBody RequestBody { get; private set; }

        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="serviceName"></param>
        /// <param name="requestBody"></param>
        public UpdateHostedServiceCommand(String serviceName, UpdateHostedServiceBody requestBody)
        {
            if (String.IsNullOrEmpty(serviceName))
            {
                throw new ArgumentException("serviceName must not be null", "serviceName");
            }
            if (requestBody == null)
            {
                throw new ArgumentNullException("requestBody");
            }
            this.ServiceName = serviceName;
            this.RequestBody = requestBody;
        }
        public override string GetRequestUri()
        {
            return String.Format("services/hostedservices/{0}", this.ServiceName);
        }
        public override HttpMethodName MethodName
        {
            get { return HttpMethodName.Put; }
        }
        public override string ContentType
        {
            get { return "application/xml"; }
        }
        public override Dictionary<String, String> GetRequestHeaders()
        {
            return null;
        }
        public override System.IO.Stream GetRequestBodyStream()
        {
            return this.GetStream(this.RequestBody.CreateText());
        }

    }
}
